package com.example.demo.controller;

import com.example.demo.log.MyLog;
import com.example.demo.redis.RedisClient;
import com.example.demo.service.FileService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @author zhanpengguo
 * @date 2019-07-04 15:12
 */
@RestController
@Api("测试接口")
@RequestMapping("/test")
public class TestController {

    @Autowired
    FileService fileService;

    @Autowired
    RedisClient redisClient;

    @GetMapping("/getOne")
    public String getOne(){
        return redisClient.get("one").toString();
    }

    @GetMapping("/setOne")
    @MyLog("插入redis")
    public void setOne(){
        redisClient.set("one","first");
    }

    @GetMapping("/download")
    public void download(HttpServletResponse response){
        fileService.download(response);
    }
}
